package com.example.langchain4j06chatimage.config;

import dev.langchain4j.community.model.dashscope.WanxImageModel;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.chat.request.ChatRequestParameters;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;
import java.util.List;

/**
 * @author wwl
 * 日期  2025/9/22 17:04
 * 版本 1.0
 * 描述 :
 */
@Configuration
public class LLMConfig
{
    /**
     * 千问图片理解
     */
    @Bean
    public ChatModel ImageModel()
    {
        ChatRequestParameters requestParameters = ChatRequestParameters.builder()
                .maxOutputTokens(10240)
                .stopSequences("</s>")
                .build();
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("aliQwen-api"))
                .modelName("qwen-vl-max")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .defaultRequestParameters(requestParameters)
                //日志
                .logRequests(true)
                .logResponses(true)
                .maxRetries(3)
                .timeout(Duration.ofSeconds(10))
                .build();
    }
    /**
     * @Description: 测试通义万象来实现图片生成，
     * 官网说明：https://help.aliyun.com/zh/model-studio/text-to-image
     *
     * @Auther: zzyybs@126.com
     */
    @Bean
    public WanxImageModel wanxImageModel()
    {
        return WanxImageModel.builder()
                .apiKey(System.getenv("aliQwen-api"))
                .modelName("wanx2.1-t2i-turbo") //图片生成 https://help.aliyun.com/zh/model-studio/text-to-image
                .build();
    }

}
